# 09/10/2022 ;
library(brms)
library(rstan)
library(tidyverse)

options(mc.cores = parallel::detectCores())

#-------------------------------------------------------------------------------
# ESS COMPARATIVE SURVEY DATA ;
#-------------------------------------------------------------------------------
rm(list=ls())
load("DATA_ESS.RData")

#-------------------------------------------------------------------------------
# RC;
#-------------------------------------------------------------------------------
bprior <- c(prior(normal( 1,10), class = b, coef = "vignette1"),
            prior(normal(-1,10), class = b, coef = "vignette3"),
            prior(normal(-8,10), class = b, coef = "vignette4"))

rc_pay <- brm(sanction_pay_no ~ vignette + (1+vignette|cntry), data=ess, 
              chains=4, iter=5000, prior=bprior, seed=1234)
summary(rc_pay)

rc_edu <- brm(sanction_edu_no ~ vignette + (1+vignette|cntry), data=ess,
              chains=4, iter=5000, prior=bprior, seed=1234)
summary(rc_edu)

rc_unp <- brm(sanction_unp_no ~ vignette + (1+vignette|cntry), data=ess, 
              chains=4, iter=5000, prior=bprior, seed=1234)
summary(rc_unp)

#-------------------------------------------------------------------------------
# SAVE FINDINGS ;
#-------------------------------------------------------------------------------
save.image("TREAT_METRIC.RData")
